package com.leyuangame.web.apps.playuser;

import com.leyuangame.dao.repository.jpa.PlayUserRepository;
import com.leyuangame.dao.repository.jpa.user.PlayUser;
import com.leyuangame.web.Handler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

@Controller

public class OnlineGameUsersController extends Handler{

    @Autowired
    private PlayUserRepository playUserRepository;

    @RequestMapping("/apps/platform/online/gameusers")
    public ModelAndView online(ModelMap map , HttpServletRequest request , @Valid String id){
        Page<PlayUser> all = playUserRepository.findAll(new PageRequest(super.getP(request), super.getPs(request)));
        map.addAttribute("playersList", all) ;
        return request(super.createAppsTempletResponse("/apps/business/platform/game/online/index"));
    }
}
